/*
 * @Date: 2022-02-13 14:09:26
 * @LastEditors: xiaole
 * @LastEditTime: 2022-02-13 23:30:24
 */

import EditorSwiper from '@/components/edit-swiper'
import EditorSearch from '@/components/edit-search'
import EditorHeader from '@/components/edit-header'
import EditorDropdown from '@/components/edit-dropdown'
import EditorTabber from '@/components/edit-tabber'
import EditorWareHouse from '@/components/edit-warehouse'
import EditorNotice from '@/components/edit-notice'
import { Button } from 'vant';

// 创建显示区
function createEditorConfig() {
    const componentList = [];
    const componentMap = {}

    return {
        componentList,
        componentMap,
        register: (component) => {
            componentList.push(component)
            componentMap[component.key] = component
        }
    }
}

export let registerConfig = createEditorConfig()

registerConfig.register({
    lebal: "文本",
    preview: () => "预览文本",
    render: () => "渲染文本",
    key: 'text'
})

registerConfig.register({
    lebal: "轮播图",
    preview: () => <EditorSwiper />,
    render: () => <EditorSwiper />,
    key: 'swiper'
})
registerConfig.register({
    lebal: "搜索框",
    preview: () => <EditorSearch />,
    render: () => <EditorSearch />,
    key: 'search'
})

registerConfig.register({
    lebal: "按钮",
    preview: () => <Button>按钮</Button>,
    render: () => <Button>按钮</Button>,
    key: 'button'
})


registerConfig.register({
    lebal: "导航栏",
    preview: () => <EditorHeader />,
    render: () => <EditorHeader />,
    key: 'header'
})

registerConfig.register({
    lebal: "下拉菜单",
    preview: () => <EditorDropdown />,
    render: () => <EditorDropdown />,
    key: 'dropdown'
})

registerConfig.register({
    lebal: "底部菜单",
    preview: () => <EditorTabber />,
    render: () => <EditorTabber />,
    key: 'tabber'
})


registerConfig.register({
    lebal: "仓库地址",
    preview: () => <EditorWareHouse />,
    render: () => <EditorWareHouse />,
    key: 'warehouse'
})

registerConfig.register({
    lebal: "公告",
    preview: () => <EditorNotice />,
    render: () => <EditorNotice />,
    key: 'natice'
})